package com.sun.mybatisplus.origin;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * 测试类
 */
public class TestQuartz {

    public static void main(String[] args) throws SchedulerException {

        JobDetail jobDetail = JobBuilder.newJob(MyJob.class)
                .withDescription("测试任务")
                .usingJobData("username","张安")
                .withIdentity("job1","group1")
                .build();

        Trigger trigger = TriggerBuilder.newTrigger()
                .withIdentity("trigger1","group1")
                .withSchedule( CronScheduleBuilder.cronSchedule("0/2 * * * * ?"))
                .startNow()
                .build();

        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

        scheduler.scheduleJob(jobDetail,trigger);
        scheduler.start();
    }
}
